package com.baomidou.mybatisplus.samples.quickstart.controller;

import com.baomidou.mybatisplus.samples.quickstart.entity.CustomEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * @author zhang
 */
@RestController
public class CustomController {

    @Resource
    private ApplicationContext applicationContext;

    @RequestMapping("/helloListener")
    public String helloListener(){
        System.out.println("模拟执行某业务逻辑A!");
        System.out.println("=======AAA================");
        System.out.println("模拟执行某业务逻辑B-> 即A执行完成后执行业务逻辑B");
        System.out.println("事件开始发布消息!");
        applicationContext.publishEvent(new CustomEvent("你好啊"));
        System.out.println("=======BBB================");
        System.out.println("模拟执行某业务逻辑B执行完毕！");
        return "success";
    }
}
